<fieldset>
    <legend>Cadastro de Eventos</legend>
    <div>
        <div class="maiscoluna" style="float: right;">
            <div id="dialog-confirm" title="Empty the recycle bin?"  >
                <p><span class="ui-icon ui-icon-alert" style="float:left;"></span>These items will be permanently deleted and cannot be recovered. Are you sure?</p>
            </div>            
            
            <h3>Atividades extras</h3>
            <form action="<?php echo $this->here;?>/atividade/index/<?php echo $data->id;?>" name="formularioAtividade" id="formularioAtividade" method="post">
            <p class="botoes" >
                <button type="submit" id="atividadenova" name="nova"  
                   <?php echo ($data->id == '' ? "disabled='disabled'" : ""); ?> >Nova</button>
                <button type="submit" id="atividadeedita" name="edita"  
                    <?php echo (empty ($atividade) ? "disabled='disabled'" : ""); ?> >Editar</button>    
                <button type="submit" id="atividadeexclui" name="exclui"  
                    <?php echo (empty ($atividade) ? "disabled='disabled'" : ""); ?> >Excluir</button>    
                <br style="clear: left;" />
            </p>
            <div size="2" id="listaatividades">
            <?php
            $cont = 1;
                    foreach ($atividade as $value) { ?>
                <p>
                <input type="radio" name="data[atividade]"  <?php echo ($cont == 1 ? "checked='checked'" : ""); ?>  id="atividade<?php echo $cont?>" value="<?php echo $value['id'] ?>" />
                <label for="atividade<?php echo $cont?>"> <?php echo $value['nome']?> </label>
                </p>
            <?php   
            $cont++;    
            } ?>
            </div>
            <br/>
            </form>
            <h3>Pre&ccedil;os</h3>
            <form action="<?php echo $this->here;?>/precoevento/index/<?php echo $data->id;?>" name="formularioPreco" id="formularioPreco" method="post">
            <p class="botoes" >
                <button type="submit" id="preconova" name="nova"  
                   <?php echo ($data->id == '' ? "disabled='disabled'" : ""); ?> >Nova</button>
                <button type="submit" id="precoedita" name="edita"  
                    <?php echo (empty ($preco) ? "disabled='disabled'" : ""); ?> >Editar</button>    
                <br style="clear: left;" />
            </p>
            <div size="2" id="listaprecos">
            <?php
            $cont = 1;
                    foreach ($preco as $value) { ?>
                <p>
                <input type="radio" name="data[data]"  <?php echo ($cont == 1 ? "checked='checked'" : ""); ?>  id="atividade<?php echo $cont?>" value="<?php echo $this->formatdate($value['dataFim']) ?>" />
                <label for="preco<?php echo $cont?>"> <?php echo $this->formatdate($value['dataFim']) ?> </label>
                </p>
            <?php   
            $cont++;    
            } ?>
            </div>            
            </form>
            <br style="clear: both;" />
        </div>   
        <div style="float: left;">
            <form action="<?php echo $this->here; ?>/evento/salvar" name="FORMULARIO" method="POST">
                <input type="hidden" name="opcao" value="Incluir" />
                <input type="hidden" name="_method" value="POST" />	
            <input type="hidden" name="data[id]" id="id" value="<?php echo $data->id; ?>"/>
            <?php
                if (isset ($success)){
                    echo "<p class='error umacoluna'>{$success}</p>";

                }
            ?>
            <p class="umacoluna">
                <label for="nome">Nome:</label> 
                <input type="text" name="data[nome]" id="nome" size="65" value="<?php echo $data->nome; ?>" />
                <br style="clear: left;" />
            </p>
            <p class="maiscoluna">
                <label for="datainicio" > Data Início: </label> 
                <input type="text" id="datainicio" name="data[dataInicio]" class="date" value="<?php echo $this->formatdate($data->dataInicio); ?>" />
                <br style="clear: left;" />
            </p>

            <p class="maiscoluna">
                <label for="datatermino"> Data Término: </label> 
                <input type="text" id="datatermino" class="date" name="data[dataFim]" value="<?php echo $this->formatdate($data->dataFim); ?>" />
                <br style="clear: left;" />
            </p>
            <p class="umacoluna">
                <label for="vagas"> Vagas: </label> 
                <input type="text" id="vagas" name="data[vagas]" value="<?php echo $data->vagas; ?>" />            
                <br style="clear: left;" />
                <label for="endereco"> Endere&ccedil;o: </label> 
                <textarea name="data[endereco]" cols="65" id="endereco"><?php echo $data->endereco; ?></textarea>
                <br style="clear: left;" />
            </p>
            <div class="umacoluna">
                <label for="cidade" >Cidade</label> 
                <div class="ui-widget">  
                    <select id="cidade" name="data[cidade_id]">
                        <option id="carregar" selected="selected" value="<?php echo $cidade['id']; ?>" ><?php echo $cidade['nome']; ?></option>
                    </select>
                </div>
                <br style="clear: left;" />
            </div>

            <p class="umacoluna">
                <label for="descricao" > Descri&ccedil;&atilde;o: </label>
                <textarea cols="65" name="data[descricao]" id="descricao"><?php echo $data->descricao; ?></textarea>
                <br style="clear: left;" />
            </p>
            <p class ="botoes umacoluna">
                <input type="submit" value=" Incluir " />
                <input type="reset" value="Cancelar" />
                <br style="clear: left;" />
            </p>
            </form>
            <br style="clear: left;" />
        </div>
        <br style="clear: left;" />
    </div>
</fieldset>

    
<script type="text/javascript" >
$(function() {

    $('#cidade').combobox();    
    
//    $('#tags').tagit({tagSource: function( request, response ) {
//               $.ajax({
//					url: "<?php // echo $this->here; ?>/evento/buscacidade/" + request.term,
//                    dataType: "json",
//					success: function( data ) {
//						response( $.map( data, function( item ) {
//							return {
//                                value: "<span style='display: none;'>"+ item.uf + "</span>"+ item.nome,
//                                label: item.nome + " - " + item.uf
//							}
//						}));
//					}
//                    });
//                }, 
//                tagsChanged: function(valor, acao){
//                    if (acao == "added")
//                        $("#local_id").attr('value', valor);
//                    else
//                        $("#local_id").attr('value', '');
//                } }); 
                
    $.datepicker.setDefaults( $.datepicker.regional[ "pt-BR" ] );
	$('#datainicio, #datatermino').datepicker({ dateFormat: 'dd/mm/yy'});      
    
    $( "#dialog:ui-dialog" ).dialog( "destroy" );
    
    $('#atividadeexclui, #precoexclui').click(function(e){
        obj =  "#" + $(this).parents("form").attr("id") + ' input:checked + label';
        return confirm("Tem certeza quer excluir ?\n" + $(obj).text());
    });
    
    $( "#dialog-confirm" ).dialog({
        resizable: false,
        height:180,
        width : 250,
        autoOpen: false,
        modal: true,
        buttons: {
            "Delete all items": function() {
                $( this ).dialog( "close" );
                return true;
            },
            Cancel: function() {
                $( this ).dialog( "close" );
                return false;
            }
        }
    });
    
	
	});    
</script>

